﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjectNocturnalFool
{
    class GameBoardScreen : UserScreen
    {

        public override void LoadContent()
        {
            base.LoadContent();

            GameboardControl gameCtrl = new GameboardControl();
            gameCtrl.x = x;
            gameCtrl.y = y;
            gameCtrl.LoadContent();
            gameCtrl.depth = ControlDepth.GameBoard;
            controls.Add(gameCtrl);

            ButtonControl buttonCtrl = new ButtonControl();
            buttonCtrl.LoadContent();
            buttonCtrl.type = Button_Type.ArenaWalk;
            buttonCtrl.x = 100;
            buttonCtrl.y = height - (Constants.ControlSmallOffsets * 2) - Constants.ButtonHeight;
            buttonCtrl.yAnchor = VerticleAnchor.Bottom;
            controls.Add(buttonCtrl);

            buttonCtrl = new ButtonControl();
            buttonCtrl.LoadContent();
            buttonCtrl.type = Button_Type.ArenaEndTurn;
            buttonCtrl.x = 0;
            buttonCtrl.y = height - (Constants.ControlSmallOffsets * 2) - Constants.ButtonHeight;
            buttonCtrl.yAnchor = VerticleAnchor.Bottom;
            controls.Add(buttonCtrl);
        }


        public override void HandleState()
        {
            base.HandleState();
                        
            Tuple<string, int, int> match = updateStatus.Find(p => p.Item1 == typeof(Button_Type).Name);
            if (match != null)
            {
                //Logic for walk button
                if (match.Item2 == (int)Button_Type.ArenaWalk)
                {
                    GameLogic.Instance.gameBoardLogic.tiles.stopMovement();
                    GameLogic.Instance.gameBoardLogic.tiles.calculateMoveOptions();
                }
                //Logic for End turn button
                if (match.Item2 == (int)Button_Type.ArenaEndTurn)
                {
                    GameLogic.Instance.gameBoardLogic.tiles.stopMovement();
                    GameLogic.Instance.gameBoardLogic.entities.nextTurn();
                }
            }
        }
    }
}
